# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
StockIcon.py
By: Denver Coneybeare <denver@sleepydragon.org>
Oct 28, 2012
"""

from __future__ import print_function
from __future__ import unicode_literals

from Error import Error
from Icon import Icon

import winapi_constants
from winapi_constants import SHGSI_ICON

class StockIcon(Icon):
    """
    An implementation of Icon where the icon is loaded from the set of stock
    Windows icons.
    """

    ICON_DOCNOASSOC = "ICON_DOCNOASSOC"  # document (blank page) no associated program
    ICON_DOCASSOC = "ICON_DOCASSOC"  # document with an associated program
    ICON_APPLICATION = "ICON_APPLICATION"  # generic application with no custom icon
    ICON_FOLDER = "ICON_FOLDER"  # folder (closed)
    ICON_FOLDEROPEN = "ICON_FOLDEROPEN"  # folder (open)
    ICON_DRIVE525 = "ICON_DRIVE525"  # 5.25" floppy disk drive
    ICON_DRIVE35 = "ICON_DRIVE35"  # 3.5" floppy disk drive
    ICON_DRIVEREMOVE = "ICON_DRIVEREMOVE"  # removable drive
    ICON_DRIVEFIXED = "ICON_DRIVEFIXED"  # fixed (hard disk) drive
    ICON_DRIVENET = "ICON_DRIVENET"  # network drive
    ICON_DRIVENETDISABLED = "ICON_DRIVENETDISABLED"  # disconnected network drive
    ICON_DRIVECD = "ICON_DRIVECD"  # CD drive
    ICON_DRIVERAM = "ICON_DRIVERAM"  # RAM disk drive
    ICON_WORLD = "ICON_WORLD"  # entire network
    ICON_SERVER = "ICON_SERVER"  # a computer on the network
    ICON_PRINTER = "ICON_PRINTER"  # printer
    ICON_MYNETWORK = "ICON_MYNETWORK"  # My network places
    ICON_FIND = "ICON_FIND"  # Find
    ICON_HELP = "ICON_HELP"  # Help
    ICON_SHARE = "ICON_SHARE"  # overlay for shared items
    ICON_LINK = "ICON_LINK"  # overlay for shortcuts to items
    ICON_SLOWFILE = "ICON_SLOWFILE"  # overlay for slow items
    ICON_RECYCLER = "ICON_RECYCLER"  # empty recycle bin
    ICON_RECYCLERFULL = "ICON_RECYCLERFULL"  # full recycle bin
    ICON_MEDIACDAUDIO = "ICON_MEDIACDAUDIO"  # Audio CD Media
    ICON_LOCK = "ICON_LOCK"  # Security lock
    ICON_AUTOLIST = "ICON_AUTOLIST"  # AutoList
    ICON_PRINTERNET = "ICON_PRINTERNET"  # Network printer
    ICON_SERVERSHARE = "ICON_SERVERSHARE"  # Server share
    ICON_PRINTERFAX = "ICON_PRINTERFAX"  # Fax printer
    ICON_PRINTERFAXNET = "ICON_PRINTERFAXNET"  # Networked Fax Printer
    ICON_PRINTERFILE = "ICON_PRINTERFILE"  # Print to File
    ICON_STACK = "ICON_STACK"  # Stack
    ICON_MEDIASVCD = "ICON_MEDIASVCD"  # SVCD Media
    ICON_STUFFEDFOLDER = "ICON_STUFFEDFOLDER"  # Folder containing other items
    ICON_DRIVEUNKNOWN = "ICON_DRIVEUNKNOWN"  # Unknown drive
    ICON_DRIVEDVD = "ICON_DRIVEDVD"  # DVD Drive
    ICON_MEDIADVD = "ICON_MEDIADVD"  # DVD Media
    ICON_MEDIADVDRAM = "ICON_MEDIADVDRAM"  # DVD-RAM Media
    ICON_MEDIADVDRW = "ICON_MEDIADVDRW"  # DVD-RW Media
    ICON_MEDIADVDR = "ICON_MEDIADVDR"  # DVD-R Media
    ICON_MEDIADVDROM = "ICON_MEDIADVDROM"  # DVD-ROM Media
    ICON_MEDIACDAUDIOPLUS = "ICON_MEDIACDAUDIOPLUS"  # CD+ (Enhanced CD) Media
    ICON_MEDIACDRW = "ICON_MEDIACDRW"  # CD-RW Media
    ICON_MEDIACDR = "ICON_MEDIACDR"  # CD-R Media
    ICON_MEDIACDBURN = "ICON_MEDIACDBURN"  # Burning CD
    ICON_MEDIABLANKCD = "ICON_MEDIABLANKCD"  # Blank CD Media
    ICON_MEDIACDROM = "ICON_MEDIACDROM"  # CD-ROM Media
    ICON_AUDIOFILES = "ICON_AUDIOFILES"  # Audio files
    ICON_IMAGEFILES = "ICON_IMAGEFILES"  # Image files
    ICON_VIDEOFILES = "ICON_VIDEOFILES"  # Video files
    ICON_MIXEDFILES = "ICON_MIXEDFILES"  # Mixed files
    ICON_FOLDERBACK = "ICON_FOLDERBACK"  # Folder back
    ICON_FOLDERFRONT = "ICON_FOLDERFRONT"  # Folder front
    ICON_SHIELD = "ICON_SHIELD"  # Security shield. Use for UAC prompts only.
    ICON_WARNING = "ICON_WARNING"  # Warning
    ICON_INFO = "ICON_INFO"  # Informational
    ICON_ERROR = "ICON_ERROR"  # Error
    ICON_KEY = "ICON_KEY"  # Key / Secure
    ICON_SOFTWARE = "ICON_SOFTWARE"  # Software
    ICON_RENAME = "ICON_RENAME"  # Rename
    ICON_DELETE = "ICON_DELETE"  # Delete
    ICON_MEDIAAUDIODVD = "ICON_MEDIAAUDIODVD"  # Audio DVD Media
    ICON_MEDIAMOVIEDVD = "ICON_MEDIAMOVIEDVD"  # Movie DVD Media
    ICON_MEDIAENHANCEDCD = "ICON_MEDIAENHANCEDCD"  # Enhanced CD Media
    ICON_MEDIAENHANCEDDVD = "ICON_MEDIAENHANCEDDVD"  # Enhanced DVD Media
    ICON_MEDIAHDDVD = "ICON_MEDIAHDDVD"  # HD-DVD Media
    ICON_MEDIABLURAY = "ICON_MEDIABLURAY"  # BluRay Media
    ICON_MEDIAVCD = "ICON_MEDIAVCD"  # VCD Media
    ICON_MEDIADVDPLUSR = "ICON_MEDIADVDPLUSR"  # DVD+R Media
    ICON_MEDIADVDPLUSRW = "ICON_MEDIADVDPLUSRW"  # DVD+RW Media
    ICON_DESKTOPPC = "ICON_DESKTOPPC"  # desktop computer
    ICON_MOBILEPC = "ICON_MOBILEPC"  # mobile computer (laptop/notebook)
    ICON_USERS = "ICON_USERS"  # users
    ICON_MEDIASMARTMEDIA = "ICON_MEDIASMARTMEDIA"  # Smart Media
    ICON_MEDIACOMPACTFLASH = "ICON_MEDIACOMPACTFLASH"  # Compact Flash
    ICON_DEVICECELLPHONE = "ICON_DEVICECELLPHONE"  # Cell phone
    ICON_DEVICECAMERA = "ICON_DEVICECAMERA"  # Camera
    ICON_DEVICEVIDEOCAMERA = "ICON_DEVICEVIDEOCAMERA"  # Video camera
    ICON_DEVICEAUDIOPLAYER = "ICON_DEVICEAUDIOPLAYER"  # Audio player
    ICON_NETWORKCONNECT = "ICON_NETWORKCONNECT"  # Connect to network
    ICON_INTERNET = "ICON_INTERNET"  # Internet
    ICON_ZIPFILE = "ICON_ZIPFILE"  # ZIP file
    ICON_SETTINGS = "ICON_SETTINGS"  # Settings
    ICON_DRIVEHDDVD = "ICON_DRIVEHDDVD"  # HDDVD Drive (all types)
    ICON_DRIVEBD = "ICON_DRIVEBD"  # BluRay Drive (all types)
    ICON_MEDIAHDDVDROM = "ICON_MEDIAHDDVDROM"  # HDDVD-ROM Media
    ICON_MEDIAHDDVDR = "ICON_MEDIAHDDVDR"  # HDDVD-R Media
    ICON_MEDIAHDDVDRAM = "ICON_MEDIAHDDVDRAM"  # HDDVD-RAM Media
    ICON_MEDIABDROM = "ICON_MEDIABDROM"  # BluRay ROM Media
    ICON_MEDIABDR = "ICON_MEDIABDR"  # BluRay R Media
    ICON_MEDIABDRE = "ICON_MEDIABDRE"  # BluRay RE Media (Rewriable and RAM)
    ICON_CLUSTEREDDRIVE = "ICON_CLUSTEREDDRIVE"  # Clustered disk

    ALL_ICONS = (
        ICON_DOCNOASSOC,
        ICON_DOCASSOC,
        ICON_APPLICATION,
        ICON_FOLDER,
        ICON_FOLDEROPEN,
        ICON_DRIVE525,
        ICON_DRIVE35,
        ICON_DRIVEREMOVE,
        ICON_DRIVEFIXED,
        ICON_DRIVENET,
        ICON_DRIVENETDISABLED,
        ICON_DRIVECD,
        ICON_DRIVERAM,
        ICON_WORLD,
        ICON_SERVER,
        ICON_PRINTER,
        ICON_MYNETWORK,
        ICON_FIND,
        ICON_HELP,
        ICON_SHARE,
        ICON_LINK,
        ICON_SLOWFILE,
        ICON_RECYCLER,
        ICON_RECYCLERFULL,
        ICON_MEDIACDAUDIO,
        ICON_LOCK,
        ICON_AUTOLIST,
        ICON_PRINTERNET,
        ICON_SERVERSHARE,
        ICON_PRINTERFAX,
        ICON_PRINTERFAXNET,
        ICON_PRINTERFILE,
        ICON_STACK,
        ICON_MEDIASVCD,
        ICON_STUFFEDFOLDER,
        ICON_DRIVEUNKNOWN,
        ICON_DRIVEDVD,
        ICON_MEDIADVD,
        ICON_MEDIADVDRAM,
        ICON_MEDIADVDRW,
        ICON_MEDIADVDR,
        ICON_MEDIADVDROM,
        ICON_MEDIACDAUDIOPLUS,
        ICON_MEDIACDRW,
        ICON_MEDIACDR,
        ICON_MEDIACDBURN,
        ICON_MEDIABLANKCD,
        ICON_MEDIACDROM,
        ICON_AUDIOFILES,
        ICON_IMAGEFILES,
        ICON_VIDEOFILES,
        ICON_MIXEDFILES,
        ICON_FOLDERBACK,
        ICON_FOLDERFRONT,
        ICON_SHIELD,
        ICON_WARNING,
        ICON_INFO,
        ICON_ERROR,
        ICON_KEY,
        ICON_SOFTWARE,
        ICON_RENAME,
        ICON_DELETE,
        ICON_MEDIAAUDIODVD,
        ICON_MEDIAMOVIEDVD,
        ICON_MEDIAENHANCEDCD,
        ICON_MEDIAENHANCEDDVD,
        ICON_MEDIAHDDVD,
        ICON_MEDIABLURAY,
        ICON_MEDIAVCD,
        ICON_MEDIADVDPLUSR,
        ICON_MEDIADVDPLUSRW,
        ICON_DESKTOPPC,
        ICON_MOBILEPC,
        ICON_USERS,
        ICON_MEDIASMARTMEDIA,
        ICON_MEDIACOMPACTFLASH,
        ICON_DEVICECELLPHONE,
        ICON_DEVICECAMERA,
        ICON_DEVICEVIDEOCAMERA,
        ICON_DEVICEAUDIOPLAYER,
        ICON_NETWORKCONNECT,
        ICON_INTERNET,
        ICON_ZIPFILE,
        ICON_SETTINGS,
        ICON_DRIVEHDDVD,
        ICON_DRIVEBD,
        ICON_MEDIAHDDVDROM,
        ICON_MEDIAHDDVDR,
        ICON_MEDIAHDDVDRAM,
        ICON_MEDIABDROM,
        ICON_MEDIABDR,
        ICON_MEDIABDRE,
        ICON_CLUSTEREDDRIVE,
    )

    def __init__(self, id, winapi=None):
        """
        Initializes a new instance of this class.
        *id* must be one if the ICON_ constants defined in this class, which
        specifies the icon to load.
        *winapi* must be the winapi module or a compatible object and will be
        used to perform the low-level operations required by this class; it is
        recommended to simply specify None (the default) in order to use the
        winapi module directly; this argument is primarily intended for use
        during unit testing of this class, and should not normally be explicitly
        specified.
        Raises ValueError if the given ID is not equal to one of the known icon
        IDs.  Raises winnnotify.Error if loading the icon with the given ID fails.
        """
        if winapi is None:
            import winapi as winapi_module
            winapi = winapi_module
        self.winapi = winapi

        icon_name = self.icon_name_by_id(id)
        if icon_name is None:
            raise ValueError("unknown icon ID: {}".format(id))
        self.icon_name = icon_name

        icon_info = winapi.SHSTOCKICONINFO()
        icon_info.cbSize = winapi.SHSTOCKICONINFO_SIZE

        hresult = winapi.SHGetStockIconInfo(
            siid=icon_name,
            uFlags=SHGSI_ICON,
            psii=icon_info,
        )
        if hresult != 0:
            raise Error("unable to load shell icon {}: "
                "SHGetStockIconInfo failed: {}".format(id, hresult))

        handle = icon_info.hIcon

        Icon.__init__(self, handle)


    def __del__(self):
        """
        Calls DestroyIcon on self.handle.
        """
        try:
            handle = self.handle
        except AttributeError:
            pass # __init__() did not complete; nothing to do
        else:
            try:
                winapi = self.winapi
            except AttributeError:
                pass # DestroyIcon function not available; nothing we can do
            else:
                if handle is not None:
                    self.handle = None
                    winapi.DestroyIcon(handle)


    @classmethod
    def icon_name_by_id(cls, id):
        """
        Translates one of the ID constants defined in this class to the
        low-level icon name to specify to SHGetStockIconInfo.
        *id* may be any object, and will be converted to the corresponding icon
        name from the winapi_constants module if it compares equal to any of the
        ICON_ constants defined in this class using the == operator.
        """
        if id == cls.ICON_DOCNOASSOC:
            icon_name = winapi_constants.SIID_DOCNOASSOC
        elif id == cls.ICON_DOCASSOC:
            icon_name = winapi_constants.SIID_DOCASSOC
        elif id == cls.ICON_APPLICATION:
            icon_name = winapi_constants.SIID_APPLICATION
        elif id == cls.ICON_FOLDER:
            icon_name = winapi_constants.SIID_FOLDER
        elif id == cls.ICON_FOLDEROPEN:
            icon_name = winapi_constants.SIID_FOLDEROPEN
        elif id == cls.ICON_DRIVE525:
            icon_name = winapi_constants.SIID_DRIVE525
        elif id == cls.ICON_DRIVE35:
            icon_name = winapi_constants.SIID_DRIVE35
        elif id == cls.ICON_DRIVEREMOVE:
            icon_name = winapi_constants.SIID_DRIVEREMOVE
        elif id == cls.ICON_DRIVEFIXED:
            icon_name = winapi_constants.SIID_DRIVEFIXED
        elif id == cls.ICON_DRIVENET:
            icon_name = winapi_constants.SIID_DRIVENET
        elif id == cls.ICON_DRIVENETDISABLED:
            icon_name = winapi_constants.SIID_DRIVENETDISABLED
        elif id == cls.ICON_DRIVECD:
            icon_name = winapi_constants.SIID_DRIVECD
        elif id == cls.ICON_DRIVERAM:
            icon_name = winapi_constants.SIID_DRIVERAM
        elif id == cls.ICON_WORLD:
            icon_name = winapi_constants.SIID_WORLD
        elif id == cls.ICON_SERVER:
            icon_name = winapi_constants.SIID_SERVER
        elif id == cls.ICON_PRINTER:
            icon_name = winapi_constants.SIID_PRINTER
        elif id == cls.ICON_MYNETWORK:
            icon_name = winapi_constants.SIID_MYNETWORK
        elif id == cls.ICON_FIND:
            icon_name = winapi_constants.SIID_FIND
        elif id == cls.ICON_HELP:
            icon_name = winapi_constants.SIID_HELP
        elif id == cls.ICON_SHARE:
            icon_name = winapi_constants.SIID_SHARE
        elif id == cls.ICON_LINK:
            icon_name = winapi_constants.SIID_LINK
        elif id == cls.ICON_SLOWFILE:
            icon_name = winapi_constants.SIID_SLOWFILE
        elif id == cls.ICON_RECYCLER:
            icon_name = winapi_constants.SIID_RECYCLER
        elif id == cls.ICON_RECYCLERFULL:
            icon_name = winapi_constants.SIID_RECYCLERFULL
        elif id == cls.ICON_MEDIACDAUDIO:
            icon_name = winapi_constants.SIID_MEDIACDAUDIO
        elif id == cls.ICON_LOCK:
            icon_name = winapi_constants.SIID_LOCK
        elif id == cls.ICON_AUTOLIST:
            icon_name = winapi_constants.SIID_AUTOLIST
        elif id == cls.ICON_PRINTERNET:
            icon_name = winapi_constants.SIID_PRINTERNET
        elif id == cls.ICON_SERVERSHARE:
            icon_name = winapi_constants.SIID_SERVERSHARE
        elif id == cls.ICON_PRINTERFAX:
            icon_name = winapi_constants.SIID_PRINTERFAX
        elif id == cls.ICON_PRINTERFAXNET:
            icon_name = winapi_constants.SIID_PRINTERFAXNET
        elif id == cls.ICON_PRINTERFILE:
            icon_name = winapi_constants.SIID_PRINTERFILE
        elif id == cls.ICON_STACK:
            icon_name = winapi_constants.SIID_STACK
        elif id == cls.ICON_MEDIASVCD:
            icon_name = winapi_constants.SIID_MEDIASVCD
        elif id == cls.ICON_STUFFEDFOLDER:
            icon_name = winapi_constants.SIID_STUFFEDFOLDER
        elif id == cls.ICON_DRIVEUNKNOWN:
            icon_name = winapi_constants.SIID_DRIVEUNKNOWN
        elif id == cls.ICON_DRIVEDVD:
            icon_name = winapi_constants.SIID_DRIVEDVD
        elif id == cls.ICON_MEDIADVD:
            icon_name = winapi_constants.SIID_MEDIADVD
        elif id == cls.ICON_MEDIADVDRAM:
            icon_name = winapi_constants.SIID_MEDIADVDRAM
        elif id == cls.ICON_MEDIADVDRW:
            icon_name = winapi_constants.SIID_MEDIADVDRW
        elif id == cls.ICON_MEDIADVDR:
            icon_name = winapi_constants.SIID_MEDIADVDR
        elif id == cls.ICON_MEDIADVDROM:
            icon_name = winapi_constants.SIID_MEDIADVDROM
        elif id == cls.ICON_MEDIACDAUDIOPLUS:
            icon_name = winapi_constants.SIID_MEDIACDAUDIOPLUS
        elif id == cls.ICON_MEDIACDRW:
            icon_name = winapi_constants.SIID_MEDIACDRW
        elif id == cls.ICON_MEDIACDR:
            icon_name = winapi_constants.SIID_MEDIACDR
        elif id == cls.ICON_MEDIACDBURN:
            icon_name = winapi_constants.SIID_MEDIACDBURN
        elif id == cls.ICON_MEDIABLANKCD:
            icon_name = winapi_constants.SIID_MEDIABLANKCD
        elif id == cls.ICON_MEDIACDROM:
            icon_name = winapi_constants.SIID_MEDIACDROM
        elif id == cls.ICON_AUDIOFILES:
            icon_name = winapi_constants.SIID_AUDIOFILES
        elif id == cls.ICON_IMAGEFILES:
            icon_name = winapi_constants.SIID_IMAGEFILES
        elif id == cls.ICON_VIDEOFILES:
            icon_name = winapi_constants.SIID_VIDEOFILES
        elif id == cls.ICON_MIXEDFILES:
            icon_name = winapi_constants.SIID_MIXEDFILES
        elif id == cls.ICON_FOLDERBACK:
            icon_name = winapi_constants.SIID_FOLDERBACK
        elif id == cls.ICON_FOLDERFRONT:
            icon_name = winapi_constants.SIID_FOLDERFRONT
        elif id == cls.ICON_SHIELD:
            icon_name = winapi_constants.SIID_SHIELD
        elif id == cls.ICON_WARNING:
            icon_name = winapi_constants.SIID_WARNING
        elif id == cls.ICON_INFO:
            icon_name = winapi_constants.SIID_INFO
        elif id == cls.ICON_ERROR:
            icon_name = winapi_constants.SIID_ERROR
        elif id == cls.ICON_KEY:
            icon_name = winapi_constants.SIID_KEY
        elif id == cls.ICON_SOFTWARE:
            icon_name = winapi_constants.SIID_SOFTWARE
        elif id == cls.ICON_RENAME:
            icon_name = winapi_constants.SIID_RENAME
        elif id == cls.ICON_DELETE:
            icon_name = winapi_constants.SIID_DELETE
        elif id == cls.ICON_MEDIAAUDIODVD:
            icon_name = winapi_constants.SIID_MEDIAAUDIODVD
        elif id == cls.ICON_MEDIAMOVIEDVD:
            icon_name = winapi_constants.SIID_MEDIAMOVIEDVD
        elif id == cls.ICON_MEDIAENHANCEDCD:
            icon_name = winapi_constants.SIID_MEDIAENHANCEDCD
        elif id == cls.ICON_MEDIAENHANCEDDVD:
            icon_name = winapi_constants.SIID_MEDIAENHANCEDDVD
        elif id == cls.ICON_MEDIAHDDVD:
            icon_name = winapi_constants.SIID_MEDIAHDDVD
        elif id == cls.ICON_MEDIABLURAY:
            icon_name = winapi_constants.SIID_MEDIABLURAY
        elif id == cls.ICON_MEDIAVCD:
            icon_name = winapi_constants.SIID_MEDIAVCD
        elif id == cls.ICON_MEDIADVDPLUSR:
            icon_name = winapi_constants.SIID_MEDIADVDPLUSR
        elif id == cls.ICON_MEDIADVDPLUSRW:
            icon_name = winapi_constants.SIID_MEDIADVDPLUSRW
        elif id == cls.ICON_DESKTOPPC:
            icon_name = winapi_constants.SIID_DESKTOPPC
        elif id == cls.ICON_MOBILEPC:
            icon_name = winapi_constants.SIID_MOBILEPC
        elif id == cls.ICON_USERS:
            icon_name = winapi_constants.SIID_USERS
        elif id == cls.ICON_MEDIASMARTMEDIA:
            icon_name = winapi_constants.SIID_MEDIASMARTMEDIA
        elif id == cls.ICON_MEDIACOMPACTFLASH:
            icon_name = winapi_constants.SIID_MEDIACOMPACTFLASH
        elif id == cls.ICON_DEVICECELLPHONE:
            icon_name = winapi_constants.SIID_DEVICECELLPHONE
        elif id == cls.ICON_DEVICECAMERA:
            icon_name = winapi_constants.SIID_DEVICECAMERA
        elif id == cls.ICON_DEVICEVIDEOCAMERA:
            icon_name = winapi_constants.SIID_DEVICEVIDEOCAMERA
        elif id == cls.ICON_DEVICEAUDIOPLAYER:
            icon_name = winapi_constants.SIID_DEVICEAUDIOPLAYER
        elif id == cls.ICON_NETWORKCONNECT:
            icon_name = winapi_constants.SIID_NETWORKCONNECT
        elif id == cls.ICON_INTERNET:
            icon_name = winapi_constants.SIID_INTERNET
        elif id == cls.ICON_ZIPFILE:
            icon_name = winapi_constants.SIID_ZIPFILE
        elif id == cls.ICON_SETTINGS:
            icon_name = winapi_constants.SIID_SETTINGS
        elif id == cls.ICON_DRIVEHDDVD:
            icon_name = winapi_constants.SIID_DRIVEHDDVD
        elif id == cls.ICON_DRIVEBD:
            icon_name = winapi_constants.SIID_DRIVEBD
        elif id == cls.ICON_MEDIAHDDVDROM:
            icon_name = winapi_constants.SIID_MEDIAHDDVDROM
        elif id == cls.ICON_MEDIAHDDVDR:
            icon_name = winapi_constants.SIID_MEDIAHDDVDR
        elif id == cls.ICON_MEDIAHDDVDRAM:
            icon_name = winapi_constants.SIID_MEDIAHDDVDRAM
        elif id == cls.ICON_MEDIABDROM:
            icon_name = winapi_constants.SIID_MEDIABDROM
        elif id == cls.ICON_MEDIABDR:
            icon_name = winapi_constants.SIID_MEDIABDR
        elif id == cls.ICON_MEDIABDRE:
            icon_name = winapi_constants.SIID_MEDIABDRE
        elif id == cls.ICON_CLUSTEREDDRIVE:
            icon_name = winapi_constants.SIID_CLUSTEREDDRIVE
        else:
            icon_name = None

        return icon_name
